package com.xnfh.home.adapter

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.xnfh.framework.bean.HomeBannerBean
import com.xnfh.home.R
import com.xnfh.home.adapter.ImageAdapter.BannerViewHolder
import com.youth.banner.adapter.BannerAdapter

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2024/1/2 15:07
 * @UpdateUser: ziheng
 * @UpdateDate: 2024/1/2 15:07
 * @UpdateRemark: 更新说明
 */
class ImageAdapter(mDatas: List<HomeBannerBean?>?) :
    BannerAdapter<HomeBannerBean?, BannerViewHolder>(mDatas) {
    //创建ViewHolder，可以用viewType这个字段来区分不同的ViewHolder
    override fun onCreateHolder(parent: ViewGroup, viewType: Int): BannerViewHolder {
        return BannerViewHolder(
            LayoutInflater.from(parent.context).inflate(R.layout.item_home_banner, parent, false)
        )
    }

    override fun onBindView(
        holder: BannerViewHolder?,
        data: HomeBannerBean?,
        position: Int,
        size: Int
    ) {
        holder?.content?.text = data?.stText
        holder?.type?.text = data?.stTypename
        holder?.itemView?.setOnClickListener {
//            val bundle = Bundle()
//            bundle.putSerializable("data", (data as HomeBannerBean))
//            MessageDetailActivity.start(context!!, bundle)
        }
    }


    inner class BannerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        var content: TextView
        var time: TextView
        var type: TextView

        init {
            content = view.findViewById(R.id.item_home_banner_connect)
            time = view.findViewById(R.id.item_home_banner_data)
            type = view.findViewById(R.id.item_home_banner_type)
        }
    }
}